<?php
//Author: Adam Bowman
/* class.JobSeeker.php */
 
//$path = $_SERVER['localhost'];
require_once( "OurDatabase.class.php");
 
Class JobSeeker extends OurDatabase{
 
 
function get_dropdown_options($table,$column){
 $sql="SELECT id,".$column." from ".$table;
 $result=mysql_query($sql);
 $options="";
 while ($row=mysql_fetch_array($result)) {
  $id=$row["id"];
  $name=$row["$column"];
  $options.="<option value=\"".$id."\">".$name."</option>";
 }
 return $options;
}
 
function get_unique_dropdown_options($table,$column){
 $sql="select distinct ".$column." from ".$table;
 $result=mysql_query($sql);
 $options="";
 while ($row=mysql_fetch_array($result)) {
  $name=$row["$column"];
  $options.="<option value=\"".$name."\">".$name."</option>";
 }
 return $options;
}
 
function single_job($Job_ID){
//if(!$_POST["Job_ID"])die("Invalid Job_ID. Go back and try again.");
 
     $sql="SELECT * from wms_job where job_id = ".$Job_ID;
     $result=mysql_query($sql);
 
     while ($row=mysql_fetch_array($result)) {
      $title=$row["job_title"];
      $desc=$row["job_description"];
      $city=$row["job_city"];
      $state=$row["job_state"];
      $zip=$row["job_zip"];
      $addr=$row["job_st_address"];
      $bus=$row["busline"];
      $wage=$row["starting_wage"];
      $open=$row["num_of_opening"];
      $dur=$row["full_part"];
      $perm=$row["perm_temp"];
      $shift=$row["shift"];
      $tran=$row["Transportation"];
      $expr=$row["exp_required"];
      $expl=$row["exp_level"];
      $req=$row["requirements"];
     }
 
     $content = "
     <tr>
      <td width=\"200\">Job Title: </td>
      <td width=\"500\">".$title."</td>
     </tr>
     <tr>
      <td>Description: </td>
      <td>".$desc."</td>
     </tr>
     <tr>
      <td>Address: </td>
      <td>".$addr."</td>
     </tr>
     <tr>
      <td>City: </td>
      <td>".$city."</td>
     </tr>
     <tr>
      <td>State: </td>
      <td>".$state."</td>
     </tr>
     <tr>
      <td>Busline: </td>
      <td>".$bus."</td>
     </tr>
     <tr>
      <td>Starting Wage: </td>
      <td>".$wage."</td>
     </tr>
     <tr>
      <td># Openings: </td>
      <td>".$open."</td>
     </tr>
     <tr>
      <td>Duration: </td>
      <td>".$dur."</td>
     </tr>
     <tr>
      <td>Temp/Perm: </td>
      <td>".$perm."</td>
     </tr>
     <tr>
      <td>Shift: </td>
      <td>".$shift."</td>
     </tr>
     <tr>
      <td>Transportation: </td>
      <td>".$tran."</td>
     </tr>
     <tr>
      <td>Experience required: </td>
      <td>".$expr."</td>
     </tr>
     <tr>
      <td>Experience level:: </td>
      <td>".$expl."</td>
     </tr>
     <tr>
      <td>Requirements: </td>
      <td>".$req."</td>
     </tr>
     ";
 
     return $content;
}
 

function job_results($Duration, $City, $State, $Type){
 $sql="SELECT job_id, job_title, job_description, job_city, job_state from wms_job";
  $added_where = false;
 
  if($Duration || $City || $State || $Type != 0)
  {
   if($Type != 0) {
    $sql = $sql." where job_type = ".$Type;
    $added_where = true;
   }
 
   if($Duration){
    if($added_where) {
     $sql = $sql." and ";
    }else{
     $sql = $sql." where ";
     $added_where = true;
    }
    $sql = $sql."perm_temp = \"".$Duration."\"";
   }
 
   if($State){
    if($added_where) {
     $sql = $sql." and ";
    }else{
     $sql = $sql." where ";
     $added_where = true;
    }
    $sql = $sql."job_state = \"".$State."\"";
   }
 
   if($City){
    if($added_where) {
     $sql = $sql." and ";
    }else{
     $sql = $sql." where ";
     $added_where = true;
    }
    $sql = $sql."job_city = \"".$City."\"";
   }
  }
 
  $result=mysql_query($sql);
 
  $table_stuff=
 "
 	<tr>
		<td />
  		<td>Job Title</td>
		<td>Location</td>
	</tr>";
 
  while ($row=mysql_fetch_array($result)) {
   $id=$row["job_id"];
   $title=$row["job_title"];
   $desc=$row["job_description"];
   $city=$row["job_city"];
   $state=$row["job_state"];
   $location = $city.', '.$state;
   $table_stuff.="<tr><td><form action=\"singlejob.php\" method=\"post\"><input type=\"hidden\" name=\"Job_ID\" value=\"".$id."\" /><button name=\"Abutton2\">More Info</button></form></td><td>".$title."</td><td align=\"left\">".$location."</td></tr>\n";
  }
 
  return $table_stuff;
 
}
 
}

 
?>